
# coding=utf-8

import unittest
from common.order.db import get_order_overview

SUCCESS = 2
MANUAL_SUCCESS = 4
parsed_dct = {u'$orderby': u'-id', u'$page': 1, u'$size': 30}
parsed_dct1 = {u'$orderby': u'-id', u'$page': 1, u'$size': 30, u'real_amount': 40}

class test_get_success_rate(unittest.TestCase):
    def test_match_success_rate(self):
        order = get_order_overview(parsed_dct)
        self.assertEqual(float(order[3]), float(42.0))

    def test_notmatch_success_rate(self):
        order = get_order_overview(parsed_dct)
        self.assertNotEqual(float(order[3]), float(213.28))

    def test_wrong_type_success_rate(self):
        order = get_order_overview(parsed_dct)
        self.assertNotEqual(order[3], float('123'))

    def test_not_match_query(self):
        order1 = get_order_overview(parsed_dct)
        order2 = get_order_overview(parsed_dct1)
        self.assertIsNot(order1, order2)

if __name__ == '__main__':
    unittest.main()

